package org.struts.listener;

import java.io.File;
import java.util.Map;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.struts.bean.XmlBean;
import org.struts.util.StrutsConfig;

public class ActionListener implements ServletContextListener {
        private static final String CONFIGLOCATION="configLocation";
	@Override
	public void contextDestroyed(ServletContextEvent arg0) {
		System.out.println("系统退出！！！");
	}

	@Override
	public void contextInitialized(ServletContextEvent sc) {
		         String fileName = sc.getServletContext().getInitParameter(CONFIGLOCATION);
		          String path =  sc.getServletContext().getRealPath(fileName);
		         Map<String,XmlBean> map=StrutsConfig.readXML(path);
		         sc.getServletContext().setAttribute(CONFIGLOCATION, map);
		         for(String key :map.keySet()){
		        	 System.out.println(key+" : "+map.get(key));
		         }
		         System.out.println("系统资源加载完毕！！！");
	}

}
